package com.yuanss.smart.fdemo.service;

import com.yuanss.smart.fdemo.mode.Customer;
import com.yuanss.smart.framework.annotation.Service;
import com.yuanss.smart.framework.helper.DatabaseHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Map;

/**
 * @Description 客户服务
 * @Date 2024/11/15 下午4:54
 * @Created by 菜到不敢run
 */
@Service
public class CustomerService {
    private static final Logger LOGGER = LoggerFactory.getLogger(CustomerService.class);

    // 获取客户列表
    public List<Customer> getCustomerList(){
        String sql = "select * from Customer";
        return DatabaseHelper.queryEntityList(Customer.class,sql);
    }

    public Customer getCustomerById(long id){
        String sql = "select * from Customer where id = ?";
        return DatabaseHelper.queryEntity(Customer.class,sql, id);
    }

    public boolean createCustomer(Map<String,Object> fieldMap){
        return DatabaseHelper.insertEntity(Customer.class,fieldMap);
    }

    public boolean updateCustomer(Map<String,Object> fieldMap, long id){
        return DatabaseHelper.updateEntity(Customer.class,id,fieldMap);
    }

    public boolean deleteCustomer(long id){
        return DatabaseHelper.deleteEntity(Customer.class,id);
    }
}
